<?php
my_component_load('testing' , false);
my_component_load('paging' , false);  
my_component_load('ijin' );
$task = isset($_GET['task']) ? $_GET['task'] : "";  
$id = isset( $_GET['id'] ) ? $_GET['id']:  0; 
$tanggal = isset( $_GET['tanggal'] ) ? $_GET['tanggal']: 0; 
$modulname = "Personalia _BN_ Waktu Kerja _BN_ Ijin _BN_ ";
 
if($_SERVER['REQUEST_METHOD'] == "POST" ){
	if($task == "create"){
		$validate =  ijin_validate( $id  );
		if($validate){
			 $content = message_multi_error($validate);
			 $content.= form_surat_ijin(   $id); 
			$pagename  = $modulname . ($id == 0 ? "Tambah data": "Ubah data")."  Ijin";
		}else{
			form_surat_ijin_submit($id);
			my_direct('index.php?com='.$_GET['com']);
		}
	}

}else{	
	/*
	if($task =='update_nomor'){
	update_table();
	my_direct('index.php?com=ijin');
	}else
	//============================
*/
	if($task == "detail_tanggal"){
		$content = list_ijin_by_date($tanggal); 
		$pagename  = $modulname . "Daftar Ijin Tanggal ". date("d-m-Y",strtotime($_GET['tanggal']));
	}elseif($task == "by_num"){
		$content = list_ijin_all(); 
		$pagename  = $modulname . "Daftar Ijin berdasarkan nomor ";
	}elseif($task == "delete"){
		my_query("DELETE FROM a_surat_ijin WHERE surat_ijin_id = {$_GET['id']} ");
		my_direct($_SERVER['HTTP_REFERER']);
	}elseif($task == "create"){
		$content = form_surat_ijin(   $id); 
		$pagename  = $modulname . "Tambah Ijin";
	}else{ 
		$pagename = $modulname . "Daftar Ijin";
		load_facebox_script();
		$content =  list_ijin($id) ; 
	}
}
generate_my_web($content, $pagename );
?>